# Maintainer:  Matheus Catarino <matheus-catarino@hotmail.com>

pkgbase=mingw-w64-expresscpp
pkgname="${MINGW_PACKAGE_PREFIX}-expresscpp"
pkgver=0.20.0
pkgrel=1
pkgdesc='Fast, unopinionated, minimalist web framework for C++ Perfect for building REST APIs.(mingw-w64)'
arch=('any')
url='https://github.com/expresscpp/expresscpp'
license=(MIT)
depends=("${MINGW_PACKAGE_PREFIX}-fmt"
         "${MINGW_PACKAGE_PREFIX}-nlohmann-json"
         "${MINGW_PACKAGE_PREFIX}-boost")
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-gcc")
source=("expresscpp-${pkgver}.tar.gz::https://github.com/expresscpp/expresscpp/archive/v${pkgver}.tar.gz"
"0001-Windows-dll-mingw.patch")
sha512sums=('afe554f01d8f43253a23daea086e9b67d9593b057534929e18ead99da5e41cb826374cf8c67b3df8c25e78aa6966fdb3afa0659482f96da67cec460882aa5461'
            'a0a9bc22817835ff35c33f8dbf6311bd35d5a6a898fac1fc99427e6212ad376c314c270cf4ac8ac899f35f446ad4b361f12cd43a04b42617263518845fbd2bc7')

prepare(){
  cd ${srcdir}/expresscpp-${pkgver}
  patch -Np1 -i "${srcdir}/0001-Windows-dll-mingw.patch"
}
build() {
  cd ${srcdir}/expresscpp-${pkgver}
        MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
        ${MINGW_PREFIX}/bin/cmake \
        -GNinja \
        -DBUILD_SHARED_LIBS=ON \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
        -B build-${MINGW_CHOST}

  cmake --build build-${MINGW_CHOST}
}

package() {
  cd ${srcdir}/expresscpp-${pkgver}/build-${MINGW_CHOST}

  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake --build . --target install
}
